export type EventName =
  | 'attach'
  | 'autoPlace'
  | 'autoPlace.end'
  | 'bendpoint.move.cancel'
  | 'bendpoint.move.cleanup'
  | 'bendpoint.move.end'
  | 'bendpoint.move.hover'
  | 'bendpoint.move.move'
  | 'bendpoint.move.out'
  | 'bendpoint.move.start'
  | 'bpmnElement.added'
  | 'canvas.destroy'
  | 'canvas.init'
  | 'canvas.resized'
  | 'canvas.viewbox.changed'
  | 'canvas.viewbox.changing'
  | 'commandStack.canvas.updateRoot.executed'
  | 'commandStack.canvas.updateRoot.postExecute'
  | 'commandStack.canvas.updateRoot.reverted'
  | 'commandStack.changed'
  | 'commandStack.connection.create.canExecute'
  | 'commandStack.connection.create.executed'
  | 'commandStack.connection.create.postExecute'
  | 'commandStack.connection.create.postExecuted'
  | 'commandStack.connection.create.preExecute'
  | 'commandStack.connection.create.reverted'
  | 'commandStack.connection.delete.executed'
  | 'commandStack.connection.delete.preExecute'
  | 'commandStack.connection.delete.reverted'
  | 'commandStack.connection.layout.executed'
  | 'commandStack.connection.layout.postExecute'
  | 'commandStack.connection.layout.postExecuted'
  | 'commandStack.connection.layout.reverted'
  | 'commandStack.connection.move.executed'
  | 'commandStack.connection.move.preExecute'
  | 'commandStack.connection.move.reverted'
  | 'commandStack.connection.reconnectEnd.canExecute'
  | 'commandStack.connection.reconnectEnd.executed'
  | 'commandStack.connection.reconnectEnd.postExecute'
  | 'commandStack.connection.reconnectEnd.postExecuted'
  | 'commandStack.connection.reconnectEnd.reverted'
  | 'commandStack.connection.reconnectStart.canExecute'
  | 'commandStack.connection.reconnectStart.executed'
  | 'commandStack.connection.reconnectStart.postExecute'
  | 'commandStack.connection.reconnectStart.postExecuted'
  | 'commandStack.connection.reconnectStart.reverted'
  | 'commandStack.connection.updateWaypoints.canExecute'
  | 'commandStack.connection.updateWaypoints.executed'
  | 'commandStack.connection.updateWaypoints.postExecute'
  | 'commandStack.connection.updateWaypoints.postExecuted'
  | 'commandStack.connection.updateWaypoints.reverted'
  | 'commandStack.element.autoResize.canExecute'
  | 'commandStack.element.copy.canExecute'
  | 'commandStack.element.paste.canExecute'
  | 'commandStack.element.updateAttachment.executed'
  | 'commandStack.element.updateAttachment.reverted'
  | 'commandStack.element.updateProperties.postExecute'
  | 'commandStack.element.updateProperties.postExecuted'
  | 'commandStack.elements.delete.postExecuted'
  | 'commandStack.elements.delete.preExecute'
  | 'commandStack.elements.move.canExecute'
  | 'commandStack.elements.move.postExecute'
  | 'commandStack.elements.move.postExecuted'
  | 'commandStack.elements.move.preExecute'
  | 'commandStack.elements.paste.canExecute'
  | 'commandStack.elements.paste.postExecute'
  | 'commandStack.elements.paste.preExecute'
  | 'commandStack.label.create.postExecute'
  | 'commandStack.lane.add.postExecuted'
  | 'commandStack.lane.add.preExecute'
  | 'commandStack.lane.resize.postExecuted'
  | 'commandStack.lane.resize.preExecute'
  | 'commandStack.lane.split.postExecuted'
  | 'commandStack.lane.split.preExecute'
  | 'commandStack.shape.append.preExecute'
  | 'commandStack.shape.attach.canExecute'
  | 'commandStack.shape.create.canExecute'
  | 'commandStack.shape.create.execute'
  | 'commandStack.shape.create.executed'
  | 'commandStack.shape.create.postExecute'
  | 'commandStack.shape.create.postExecuted'
  | 'commandStack.shape.create.preExecute'
  | 'commandStack.shape.create.revert'
  | 'commandStack.shape.create.reverted'
  | 'commandStack.shape.delete.execute'
  | 'commandStack.shape.delete.executed'
  | 'commandStack.shape.delete.postExecute'
  | 'commandStack.shape.delete.postExecuted'
  | 'commandStack.shape.delete.preExecute'
  | 'commandStack.shape.delete.revert'
  | 'commandStack.shape.delete.reverted'
  | 'commandStack.shape.move.executed'
  | 'commandStack.shape.move.postExecute'
  | 'commandStack.shape.move.postExecuted'
  | 'commandStack.shape.move.preExecute'
  | 'commandStack.shape.move.reverted'
  | 'commandStack.shape.replace.postExecute'
  | 'commandStack.shape.replace.postExecuted'
  | 'commandStack.shape.resize.canExecute'
  | 'commandStack.shape.resize.executed'
  | 'commandStack.shape.resize.postExecute'
  | 'commandStack.shape.resize.postExecuted'
  | 'commandStack.shape.resize.preExecute'
  | 'commandStack.shape.resize.reverted'
  | 'commandStack.shape.toggleCollapse.executed'
  | 'commandStack.shape.toggleCollapse.postExecuted'
  | 'commandStack.shape.toggleCollapse.reverted'
  | 'commandStack.spaceTool.postExecuted'
  | 'commandStack.spaceTool.preExecute'
  | 'connect.canceled'
  | 'connect.cleanup'
  | 'connect.end'
  | 'connect.ended'
  | 'connect.hover'
  | 'connect.move'
  | 'connect.out'
  | 'connect.start'
  | 'connection.added'
  | 'connection.changed'
  | 'connection.remove'
  | 'connection.removed'
  | 'connectionSegment.move.cancel'
  | 'connectionSegment.move.cleanup'
  | 'connectionSegment.move.end'
  | 'connectionSegment.move.hover'
  | 'connectionSegment.move.move'
  | 'connectionSegment.move.out'
  | 'connectionSegment.move.start'
  | 'contextPad.close'
  | 'contextPad.create'
  | 'create.cleanup'
  | 'create.end'
  | 'create.hover'
  | 'create.move'
  | 'create.out'
  | 'create.rejected'
  | 'create.start'
  | 'detach'
  | 'diagram.clear'
  | 'diagram.destroy'
  | 'diagram.init'
  | 'directEditing.activate'
  | 'directEditing.cancel'
  | 'directEditing.complete'
  | 'directEditing.resize'
  | 'drag.cleanup'
  | 'drag.init'
  | 'drag.move'
  | 'drag.start'
  | 'element.changed'
  | 'element.click'
  | 'element.dblclick'
  | 'element.hover'
  | 'element.marker.update'
  | 'element.mousedown'
  | 'element.mousemove'
  | 'element.out'
  | 'element.paste'
  | 'element.updateId'
  | 'elements.changed'
  | 'elements.delete'
  | 'elements.paste.rejected'
  | 'global-connect.canceled'
  | 'global-connect.cleanup'
  | 'global-connect.drag.canceled'
  | 'global-connect.drag.ended'
  | 'global-connect.ended'
  | 'global-connect.hover'
  | 'global-connect.init'
  | 'global-connect.out'
  | 'hand.canceled'
  | 'hand.end'
  | 'hand.ended'
  | 'hand.init'
  | 'hand.move.canceled'
  | 'hand.move.end'
  | 'hand.move.ended'
  | 'hand.move.move'
  | 'i18n.changed'
  | 'import.parse.complete'
  | 'lasso.canceled'
  | 'lasso.cleanup'
  | 'lasso.end'
  | 'lasso.ended'
  | 'lasso.move'
  | 'lasso.selection.canceled'
  | 'lasso.selection.end'
  | 'lasso.selection.ended'
  | 'lasso.selection.init'
  | 'lasso.start'
  | 'mydrag.move'
  | 'mydrag.start'
  | 'palette.create'
  | 'popupMenu.open'
  | 'render.connection'
  | 'render.getConnectionPath'
  | 'render.getShapePath'
  | 'render.shape'
  | 'resize.cleanup'
  | 'resize.end'
  | 'resize.move'
  | 'resize.start'
  | 'selection.changed'
  | 'shape.added'
  | 'shape.changed'
  | 'shape.move.cleanup'
  | 'shape.move.end'
  | 'shape.move.hover'
  | 'shape.move.move'
  | 'shape.move.out'
  | 'shape.move.rejected'
  | 'shape.move.start'
  | 'shape.remove'
  | 'shape.removed'
  | 'spaceTool.canceled'
  | 'spaceTool.cleanup'
  | 'spaceTool.end'
  | 'spaceTool.ended'
  | 'spaceTool.move'
  | 'spaceTool.selection.canceled'
  | 'spaceTool.selection.cleanup'
  | 'spaceTool.selection.end'
  | 'spaceTool.selection.ended'
  | 'spaceTool.selection.init'
  | 'spaceTool.selection.move'
  | 'spaceTool.selection.start'
  | 'sum'
  | 'tool-manager.update';

type EventNameType = string | EventName;

export interface IEventBus {
  on(events: Array<EventNameType> | EventNameType, priority: number, callback: Function, callbackScope?: any): void;
  on(events: Array<string> | string, callback: Function, callbackScope?: any): void;

  once(events: Array<EventNameType> | EventNameType, priority: number, callback: Function, callbackScope: any): void;
  once(events: Array<EventNameType> | EventNameType, callback: Function, callbackScope: any): void;
  off(event: EventNameType, callback?: Function): void;
  fire(nameOrType: EventNameType | {type: EventNameType}, data?: any): any;
}
